<?php
session_start();
require("../conn.php");
     
         $id=($_POST['id']);
		 $username=($_POST['username']);
		 $mail=($_POST['email']);
		 $phone=($_POST['phone']);
		 $permission=($_POST['permission']);
		  $section=$_POST['selections'];
		 
		  $listpsermit='';
		  if($permission!=1)
		foreach ($section as $t)
		{

			$listpsermit.= $t.",";
		}
		if(strlen($listpsermit)>0)
		{
		$listpsermit= substr($listpsermit,0,strlen($listpsermit)-1);
		}
$sql=sprintf("update tbluser set username='%s',email='%s',phone='%s',section_ids='%s',permission='%s' where id='%s'", $username,$mail,$phone,$listpsermit,$permission,$id);																														
			$kq=mysql_query($sql)or die(mysql_error());
	 
	
	
			if(!$kq)
			{ 
				?>
				<script language="javascript">
				alert("không thêm được ");
			
				</script>
				<?php
					header("Location:default.php?man=usere?id=".$id);
			}
			else
			{
				
			   
			header("Location:../default.php?man=user");
				
			}

		

?>
